import React, { useEffect, useState } from "react";
import { NavBar } from "antd-mobile";
import styles from "./Index.module.css";
import { useNavigate, useParams } from "react-router-dom";
import instance from "../../../api/request";
import dayjs from "dayjs";
function Index() {
  const nav = useNavigate();
  const [list, setList] = useState([]);
  const { doctorId } = useParams();
  const [page, setPage] = useState(1);
  const [count, setCount] = useState(5);

  useEffect(() => {
    instance
      .get("/api/user/inquiry/v1/findDoctorEvaluateList", {
        params: {
          doctorId: doctorId,
          page: page,
          count: count,
        },
      })
      .then((res) => {
        console.log(res);
        setList(res.data.result);
      });
  }, []);

  return (
    <div className={styles.plz}>
      <div className={styles.tou}>
        <NavBar onBack={() => nav(-1)}>评论列表</NavBar>
      </div>

      <div className={styles.list}>
        {list.map((item, index) => {
          return (
            <div key={index} className={styles.listx}>

              <div style={{display:'flex',gap:'10px'}}>

                <div style={{marginLeft:'10px'}}>
                  <img src={
                    item.headPic && item.headPic.includes('.') ? item.headPic:''
                } alt=""  />
                </div>

                <div>{item.nickName}</div>

                <div style={{marginLeft:'170px'}}>{dayjs(item.commentTime).format('YYYY-MM-DD')}</div>
              </div>

              <div className={styles.content}>
                {item.content}
              </div>

            </div>
          );
        })}
      </div>
    </div>
  );
}

export default Index;
